module odefu.engine.entity.Entity;

import std.algorithm;
import std.array;

import odefu.engine.component.Component;

public Entity createEntity(string name)
{
	return new EntityImpl(name);
}

public interface Entity
{
	public Component getComponent(string name);
	
	public Component[] getComponents();
	
	public void addComponent(Component component);
	
	public Component removeComponent(string name);
	
	public Component removeComponent(Component component);
	
	@property public string name();
}

private class EntityImpl : Entity
{
	private string _name;
	
	private Component[] components = [];
	
	public this(string name)
	{
		_name = name;
	}
	
	public Component getComponent(string name)
	{
		auto ret = filter!(comp => comp.name == name)(components);
		return ret.front;
	}
	
	public Component[] getComponents()
	{
		return components;
	}
	
	public void addComponent(Component component)
	{
		
	}
	
	public Component removeComponent(string name)
	{
	}
	
	public Component removeComponent(Component component)
	{
	}
	
	@property public string name()
	{
		return _name;
	}
}